// Bring out your Dead - White Wolf character Management System.
// Copyright (C) 2008 Adam Ness
// 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

using System;
using System.Collections.Generic;

namespace Boyd.Model
{
	/// <summary>
	/// Description of Game.
	/// </summary>
	public class Game
	{
		private String name;
		private String fileName;
		private IList<String> players;
		private IList<Character> characters;

		public Game()
		{
			players = new List<String>();
			characters = new List<Character>();
		}
		
		public string FileName {
			get { return fileName; }
			set { fileName = value; }
		}
		
		public string Name {
			get { return name; }
			set { name = value; }
		}
		
		public IEnumerable<String> Players {
			get { return players; }
		}
		
		public IEnumerable<Character> Characters {
			get { return characters; }
		}
		
		public void AddCharacter( Character character ) {
			characters.Add( character );
			if( !players.Contains( character.Player ) ) {
				players.Add( character.Player );
			}
		}
		
		public void RemoveCharacter( Character character ) {
			characters.Remove( character );
		}
		
		public void AddPlayer( String player ) {
			players.Add( player );
		}
		
		public void RemovePlayer( String player ) {
			players.Remove( player );
		}
		
		public bool PlayerHasCharacters( String player ) {
			bool playerHasCharacters = false;
			foreach( Character character in characters ) {
				if( character.Player.Equals( player ) ) {
					playerHasCharacters = true;
					break;
				}
			}
			return playerHasCharacters;
		}
		
		public int CountPlayerCharacters( String player ) {
			int count = 0;
			foreach( Character character in characters ) {
				if( character.Player.Equals( player ) ) {
					count++;
				}
			}
			return count;
		}
		
	}
}
